package com.xjm.ips.controller.salary;

import com.xjm.ips.entity.AjaxJson;
import com.xjm.ips.entity.Employee;
import com.xjm.ips.entity.MyPage;
import com.xjm.ips.entity.Salary;
import com.xjm.ips.service.EmployeeBasiService;
import com.xjm.ips.service.SalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/salary/sobcfg/")
public class SalarySobConfigController {
    @Autowired
    EmployeeBasiService employeeBasiService;
    @Autowired
    SalaryService salaryService;

    @GetMapping("/")
    public MyPage getEmployeeByPageWithSalary(@RequestParam(defaultValue = "1") Integer pageNo,
                                              @RequestParam(defaultValue = "10")Integer pageSize){
        return  employeeBasiService.getEmployeeByPageWithSalary(pageNo,pageSize);
    }

    @GetMapping("/getallsalaries")
    public List<Salary> getAllSalaries(){
        List<Salary> data = (List<Salary>)salaryService.getAllSalaries(null, null).getData();
        return data;
    }

    @PutMapping("/")
    public AjaxJson updateEmploeeOfSalaryById(Integer employeeId,Integer salaryId){
        if(employeeBasiService.updateEmploeeOfSalaryById(employeeId,salaryId)!=0){
            return AjaxJson.ok("更新员工工资账套成功!");
        }
        return AjaxJson.error("更新员工工资账套失败!");
    }
}
